<!DOCTYPE html>
<html>
<head>
<base href="${basePath}">
<meta charset="UTF-8">
<title>创建产品</title> $!{include("import_js_css.html")}
<script>
	function documentReady() {
		var msg = '${msg}';
		if (msg == 'cpf') {
			var cpf = alert("创建产品失败!");
			setTimeout(function() {
				cpf.close().remove();
			}, 1000);
		}else if(msg){
			var cpf = alert(msg);
			setTimeout(function() {
				cpf.close().remove();
			}, 1000);
		}
		
		$("#selProductType").select2({
			width: "100%",
			minimumResultsForSearch: -1
		});
	}
</script>
</head>
<body>
	$!{include("header.html")}
	<div class="menu_all">
		<div class="div_search_result clear">
			<div class="panel-heading panel-result-title">
				<h3 class="panel-title">创建产品</h3>
			</div>
			<div class="panel-form-add">
				<form class="form-horizontal" role="form" action="yueyogaAdmin/addProduct.jhtml" method="POST">
					<div class="panel-form-layout">
						<label for="txtProductName" class="col-sm-1 control-label">产品名称</label>
						<div class="col-sm-3">
							<input type="text" required class="form-control" name="name" id="txtProductName" value="">
						</div>
						<label for="inputMemberLevel" class="col-sm-1 control-label">产品类型</label>
						<div class="col-sm-3">
							<select class="selectpicker show-tick" data-width="100%" name="type" id="selProductType">
								<option value=""> </option>
								<option value="101">按次卡</option>
								<option value="102">按时间</option>
								<option value="107">按金额</option>
								<option value="103">年卡</option>
								<option value="104">季卡</option>
								<option value="105">月卡</option>
								<option value="106">半月卡</option>
								<option value="108">实时扣费</option>
							</select>
						</div>
						<br /> <br /> 
						
						<label for="txtPrice" class="col-sm-1 control-label">产品价格</label>
						<div class="col-sm-3">
							<input type="text" class="form-control" name="price" onkeydown="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')" id="txtPrice" required value="">
						</div>
						<div id="div_counts">
							<label for="txtProductCounts" class="col-sm-1 control-label">产品次数</label>
							<div class="col-sm-3">
								<input type="text" maxLength="8" onkeypress="return isNum(event)" onkeydown="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')"
									class="form-control" name="counts" id="txtProductCounts" value="">
							</div>
						</div>
						
						<br /> <br /> <label for="txtPrice" class="col-sm-1 control-label">每周限制</label>
						<div class="col-sm-3">
							<select class="selectpicker" data-width="100%" name="limitOfWeek" id="limitOfWeek">
								<option value="">不限制</option>
								<option value="1">1次</option>
								<option value="2">2次</option>
								<option value="3">3次</option>
								<option value="4">4次</option>
								<option value="5">5次</option>
								<option value="6">6次</option>
								<option value="7">7次</option>
								<option value="8">8次</option>
								<option value="9">9次</option>
								<option value="10">10次</option>
							</select>
						</div>
						
						<br /> <br /> 
						<label for="txtRemarks" class="col-sm-1 control-label">产品备注</label>
						<div class="col-sm-3">
							<textarea id="txtRemarks" name="remarks" class="form-control panel-form-address"></textarea>
						</div>
						
						<br /> <br /> <br /> <br />
						<div id="div_datetime" class="panel-space" style="display: none;">
							<label for="inputStartDate1" class="col-sm-1 control-label">起始日期</label>
							<div class="col-sm-3">
								<div id="inputStartDate1" class="input-group date" data-date-format="YYYY-MM-DD">
									<input id="inputStart1" name="beginTime" type='text' class="form-control" /> <span class="input-group-addon"><span class="glyphicon glyphicon-time"></span> </span>
								</div>
							</div>
							<label for="inputEndDate1" class="col-sm-1 control-label">截止日期</label>
							<div class="col-sm-3">
								<div id="inputEndDate1" class="input-group date" data-date-format="YYYY-MM-DD">
									<input id="inputEnd1" name="endTime" type='text' value="${enddate1}" class="form-control" /> <span class="input-group-addon"><span class="glyphicon glyphicon-time"></span> </span>
								</div>
							</div>
						</div>
						<div class="panel-btn-search">
							<button type="submit" class="btn btn-default btn-ade-default panel-mr">保存</button>
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
</body>
<script type="text/javascript">
	$(".date").datetimepicker({
		language : "zh-CN",
		pickTime : false
	});
	$("#inputStartDate1").on("dp.change", function(e) {
		console.log(e);
		$("#inputEndDate1").data("DateTimePicker").setMinDate(e.date);
	});

	$("#inputEndDate1").on("dp.change", function(e) {
		$("#inputStartDate1").data("DateTimePicker").setMaxDate(e.date);
	});
	$(function() {
		$("#selProductType")
				.change(
						function() {
							var type = $(this).val();
							if (type == '101') {
								$("#div_datetime").hide();
								$("#div_counts").show();
							} else if (type == '102') {
								$("#div_counts").hide();
								$("#div_datetime").show();
							} else if (type == '103' || type == '104'
									|| type == '105' || type == '106'
									|| type == '107' || type == '108') {
								$("#div_counts").hide();
								$("#div_datetime").hide();
							}
						});
	});
	function isNum(e) {
		var k = window.event ? e.keyCode : e.which;
		if (((k >= 48) && (k <= 57)) || k == 8 || k == 0) {
		} else {
			if (window.event) {
				window.event.returnValue = false;
			} else {
				e.preventDefault(); //for firefox 
			}
		}
	}
	function clearNoNumOfAlert(obj) {

		//得到第一个字符是否为负号
		var t = obj.value.charAt(0);
		//先把非数字的都替换掉，除了数字和.   
		obj.value = obj.value.replace(/[^\d.]/g, "");
		//必须保证第一个为数字而不是.   
		obj.value = obj.value.replace(/^\./g, "");
		//保证只有出现一个.而没有多个.   
		obj.value = obj.value.replace(/\.{2,}/g, ".");
		//保证.只出现一次，而不能出现两次以上   
		obj.value = obj.value.replace(".", "$#$").replace(/\./g, "").replace(
				"$#$", ".");
		//如果第一位是负号，则允许添加
		if (t == '-') {
			obj.value = '-' + obj.value;
		}
	}
</script>
</html>
